<%@ page pageEncoding="UTF-8"%>
<%@ include file="/common/token.jsp"%>
<%@ include file="/common/user.jsp"%>
<%@ include file="/common/operatehistory.jsp"%>
<%
	User me = userByUid(token.getUid());
	Integer deptId = me.getDeptId();
	if (deptId == null) {
		Tools.encryptPrint(out, new Message(30041, "没有你这个团队的信息"));
		return;
	}
	List<Map> list = QBuilder.db("basedb").select("new map(u.id as id, u.name as name, u.avatar  as avatar, case when u.title is null then '' else u.title end as title, u.jsonString as json, u.gender as gender, u.type as type, u.phone as phone)").from("User as u, OperateHistory as o").where(new Where("u.hospital=", hospital).and("u.deptId=", deptId).and("u.status=", STATUS_ENABLE).and("u.type=", USER_EMPLOYEE).and("u.jsonString not like '%\"role\":\"2\"%'").and("o.hospital=", hospital).and("o.oid=", me.getId()).and("o.status=", STATUS_ENABLE).and("o.category=", SECTION_SECRETARY).and("o.operate=", ATTENTION).and("o.uid=u.id")).query().getResultObj();
	for (Map expert:list) {
		User user = User.fromMap(expert, User.class);
		expert.put("avatar", getDefaultAvatar(user));
		Map jsonMap = JSONUtil.fromJson(expert.remove("json") + "", new TypeReference<Map>(){});
		expert.put("specialty", Tools.getDesc(jsonMap.get("specialty"), "暂无擅长信息"));
		expert.put("introduce", Tools.getDesc(jsonMap.get("introduce"), "暂无介绍信息"));
		expert.put("role", Tools.getDesc(jsonMap.get("role"), "1"));
		expert.put("phone", Tools.getDesc(user.getPhone(), "暂无手机号"));   
		expert.put("authorized", 1);
	}
	if (isEmpty(list))
		msg.setErrcodeAndErrmsg(30041, "您还没有服务的医生呢");
	msg.put("data", list);
	Tools.encryptPrint(out, msg);
%>
